package week12;

import java.util.ArrayList;

public class StudentDemo {
    public static void main(String[] args) {
        ArrayList<Student>students=new ArrayList<>();
        Student student1 = new Student("1","张三","信息与计算科学",80.3);
        Student student2 = new Student("2","李四","信息与计算科学",90.5);
        Student student3 = new Student("3","王五","信息与计算科学",85.8);
        students.add(student1);
        students.add(student2);
        students.add(student3);
        for (Student student:students) {
            System.out.println(student);
        }
        Student duplicateStudent=new Student("1","张三","信息与计算",80.3);
        if (students.contains(duplicateStudent)) {
            System.out.println("重复");
        }else {
            students.add(duplicateStudent);
            System.out.println("数据已经入库");
        }
        Student newStudent=new Student("4","李六","信息及与计算科学",95.2);
            if (students.contains(newStudent)){
                System.out.println("重复");
            }else {
                students.add(newStudent);
                System.out.println("数据已经入局");
            }
        }

    }

